﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        initControl();
        gridList()
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            postData: { keyword: $("#txt_keyword").val() },
            url: "/Duty/GetGridJson",
            height: $(window).height() - 128,
            colModel: [
                 { label: "主键", name: "Id", hidden: true, key: true },
                  { label: "名称", name: "Name", width: 100, align: 'left' },
                  { label: '编码', name: 'Code', width: 100, align: 'left' },
                  { label: '说明', name: 'Description', width: 150, align: 'left' },
                  { label: "有效", name: "zt", width: 80, align: "left", formatter: function (cellvalue) { return cellvalue == "1" ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>"; } },
                  { label: '创建人', name: 'CreatorCode', width: 100, align: 'left' },
                  { label: '创建时间', name: 'CreateTime', width: 100, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
                  { label: '最后修改', name: 'LastModifierCode', width: 100, align: 'left' },
                  { label: '最后修改时间', name: 'LastModifyTime', width: 100, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
                  { label: '排序', name: 'px', width: 40, align: 'left' }
            ],
            pager: "#gridPager",
            sortname: 'CreateTime desc',
        });
        function reloadGrid() {
            $("#gridList").jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        }
        $("#btn_search").click(reloadGrid);
        $("#txt_keyword").keydownEnterEvent(reloadGrid);
    }

    function initControl() {

    }

</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="名称/编码" style="width: 180px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>


